package com.alibaba.sdk.exception;

import com.alibaba.sdk.constant.SymbolConstant;
import com.alibaba.sdk.enums.ErrorCodeEnums;
import lombok.Data;

/**
 * 系统异常类
 *
 * @ author  Shawn(Shawn_0217@163.com)
 * @ date    2021/4/27 9:38
 * @ company Alibaba
 */
@Data
public class BusinessException extends RuntimeException{

    private static final long serialVersionUID = -5189478748219752577L;

    private String errorCode;

    private String errorMessage;

    public BusinessException(String errorCode, String errorMessage) {
        super(errorCode + SymbolConstant.COMMA + errorMessage);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public BusinessException(ErrorCodeEnums error) {
        super(error.getErrorCode() + SymbolConstant.COMMA + error.getErrorMsg());
        this.errorCode = error.getErrorCode();
        this.errorMessage = error.getErrorMsg();
    }

}
